/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var maxDepth = function (root) {
    let maxLen = 0
    const tool = (root, num) => {
        if (root === null) {
            maxLen = Math.max(maxLen, num - 1)
            return
        }
        tool(root.left, num + 1)
        tool(root.right, num + 1)

    }
    tool(root, 1)
    return maxLen
};
